package cn.com.main;


import org.apache.commons.lang3.RandomUtils;

import java.io.FileWriter;
import java.io.IOException;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;

public class MockDataGenerator {

    public static void main(String[] args) {
        JSONArray data = new JSONArray();

        // Generate 10000 mock data entries
        for (int i = 0; i < 200; i++) {
            JSONObject entry = new JSONObject();
            entry.put("unit_code", "100148");
            entry.put("unit_name", "发展委员会");
            entry.put("id", "BD82074AE0CD3C" + i + 45);
            entry.put("personal_identity_category_name", getRandomCategory());
            entry.put("seu_card_id", getRandomCardId());
            entry.put("personal_identity_category_code", getRandomCategoryCode());
            entry.put("full_name", getRandomFullName());
            entry.put("person_status", getRandomStatus());
            entry.put("phone_num", getRandomPhoneNumber());
            entry.put("email", getRandomEmail());
            data.put(entry);
        }

        // Write to file
        try (FileWriter file = new FileWriter("mock_data.json")) {
            file.write(data.toString());
            file.flush();
            System.out.println("Mock data generated successfully.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // Helper methods for generating random data
    private static String getRandomCategory() {
        String[] categories = {"教职工", "本科生", "教师", "临时人员"};
        //return categories[(int) (Math.random() * categories.length)];
        return "教职工";
    }

    private static String getRandomCardId() {
        return String.format("%018d", RandomUtils.nextLong(100000000000000000L, 999999999999999999L));
    }

    private static String getRandomCategoryCode() {
        //return String.valueOf((int) (Math.random() * 4) + 1);
        return "1";
    }

    private static String getRandomFullName() {
        String[] firstNames = {"张三", "李四", "王五", "赵六", "刘七"};
        String[] lastNames = {"小", "大", "明", "红", "芳"};
        return firstNames[(int) (Math.random() * firstNames.length)] +
                lastNames[(int) (Math.random() * lastNames.length)] + String.valueOf(Math.random()).substring(2, 6);
    }

    private static String getRandomStatus() {
        return Math.random() < 0.5 ? "1" : "0";
    }

    private static String getRandomPhoneNumber() {
        return "188" + ((int) (Math.random() * 90000000) + 10000000);
    }

    private static String getRandomEmail() {
        return "test" + ((int) (Math.random() * 100000) + 10000) + "@163.com";
    }
}
